import pyperclip
import sys
import webbrowser
import re

if len(sys.argv) > 1:
    # Get address from command line.
    address = ' '.join(sys.argv[1:])
else:
    # Get address from clipboard.
    address = pyperclip.paste()

urlRegex = re.compile(r'.*?\.(com|net|cn|org|tv)')
if urlRegex.search(str(sys.argv[1:])) is None:
    url = 'https://www.baidu.com/baidu?wd=' + address
else:
    url = 'http://' + address

print('Baidu Searching...')
webbrowser.open(url)
